/*
 * @Author: your name
 * @Date: 2021-12-22 16:19:00
 * @LastEditTime: 2021-12-22 16:19:01
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \briup_am\am-server\app.js
 */
class AppBootHook {
    constructor(app) {
      this.app = app;
    }
  
    async didReady() {
      // 应用已经启动完毕
      const ctx = await this.app.createAnonymousContext();
      let params = {
        page:1,
        pageSize:100,
        online_status:1,
      }
      const devices = await ctx.service.device.pageQuery(params);
      // 依次打开所有在线设备
      for(let d of devices.list){
        await ctx.service.device.openDevice(d.id);
      }
      console.log('成功启动了',devices.list.length,'个设备');
    }
  }
  
  module.exports = AppBootHook;